import React, { Fragment } from 'react';
import { connect } from 'dva';
import BasePage from './BasePage'
import { Card, Space, PageHeader, Breadcrumb, Descriptions, Result } from 'antd'
import style from '../assets/less/mechanismOperation.less'
import CurrentLocation from '../components/currentLocation'
import VerificationTechnologyTable from '../components/table/verificationTechnologyTable'
import TestTechnologyTable from '../components/table/testTechnologyTable'
import breadArr from '../constant/breadArr'

class MechanismOperationPage extends React.Component {
    constructor(props) {
        super(props)
    }

    componentDidMount() {
        this.props.dispatch({
            type: "mechanismOperation/getMechanismById",
            data: { id: this.props.user.id }
        })
    }

    checkLogin = user => {
        if (user.userType == 4 && user.mechanismType == 1) {
            return (
                <div id={style.verificationTechnologyTable}>
                    <VerificationTechnologyTable></VerificationTechnologyTable>
                </div>
            )
        }

        if (user.userType == 4 && user.mechanismType == 2) {
            return (
                <div id={style.verificationTechnologyTable}>
                    <TestTechnologyTable></TestTechnologyTable>
                </div>
            )
        }

        if (user == {} || user.userType != 4) {
            return (
                <Result
                    status="warning"
                    title="请先登录机构账号后再查看相关操作！"
                >
                </Result>
            )
        }
    }

    render() {
        return (
            <BasePage>
                <CurrentLocation breadArr={breadArr.MechanismOperationPage}></CurrentLocation>
                {this.checkLogin(this.props.user)}
            </BasePage>
        )
    }
}

const mapStateToProps = state => {
    let user = state.app.user
    return {
        user
    }
}

export default connect(mapStateToProps)(MechanismOperationPage)